package org.rency.mq.activemq.listener.handler.impl;

import org.rency.mq.activemq.constant.DestinationType;
import org.rency.mq.activemq.request.MQRequest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public abstract class AbstractMessageHandler<T> extends AbstractHandler<T> {
	private static Logger logger = LoggerFactory.getLogger(AbstractMessageHandler.class);
	private int actionId;
	private String destination;
	private int destinationType = DestinationType.QUEUE;

	/**
	 * 是否为监听的ActionId
	 * @param actionId
	 * @return
	 */
	public boolean isListening(int actionId){
		return this.actionId == actionId;
	}

    /**
     * 将消息转换为MQRequest对象
     */
    @Override
    public MQRequest convertToMQRequest(T request) {
        if (MQRequest.class.isAssignableFrom(request.getClass())) {
            return (MQRequest) request;
        }
        return null;
    }
	
	public int getActionId() {
		return actionId;
	}

	public void setActionId(int actionId) {
		this.actionId = actionId;
	}

	public String getDestination() {
		return destination;
	}

	public void setDestination(String destination) {
		this.destination = destination;
	}

	public int getDestinationType() {
		return destinationType;
	}

	public void setDestinationType(int destinationType) {
		this.destinationType = destinationType;
	}
}
